package cn.edu.hziee;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ServletDemo2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.print("post提交方式<br/>");
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i;j++) {
                out.print(j+ "*" + i + "=" + j * i+" ");
            }
            out.print("<br/>");
        }
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            out.print("get提交方式<br/>");
            for (int i = 1; i <= 9; i++) {
                for (int j = 1; j <= i;j++) {
                    out.print(j+ "*" + i + "=" + j * i+" ");
                }
                out.print("<br/>");
            }
        }
    }

